package top.sdaily.storage;

import java.io.File;

import org.springframework.beans.factory.annotation.Value;

import org.springframework.stereotype.Service;
import top.sdaily.storage.util.FileUtil;

/**
 * Created by soya on 2017/3/19.
 */
@Service
public class LocalStorageManager implements StorageManager {

    @Value("img.path.root")
    private String  rootPath;

    @Override
    public Storage storage(Storage storage) {

        return null;
    }

    @Override
    public void remove(Storage storage) {

    }

    private String uploadFile(Storage storage) {
        storage.setSaveType("local");
        FileUtil.generationFileInfo(storage);
        File out = new File(storage.getAccessPath());
        if (!out.getParentFile().exists()) {
            out.getParentFile().mkdirs();
        }
        FileUtil.saveFile(rootPath + storage.getAccessPath(), storage.getFile());

        return storage.getFileName();
    }



}
